package com.yh.correct.service.impl;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yh.correct.dao.IRegisterMapper;
import com.yh.correct.model.Page;
import com.yh.correct.model.Register;
import com.yh.correct.service.IRegisterService;
/**
 *@author Administrator
 *@注释 : 服刑人员报到服务层实体类
*	
*/
@Service
public class RegisterServiceImpl implements IRegisterService {
	private static Logger logger = LogManager.getLogger(RegisterServiceImpl.class);
	@Autowired
	private IRegisterMapper iregisterMapper;

	/**
	 * 
	 *@author Administrator
	 *@注释 : 增加服刑报到人员
     */
	@Override
	public int addRegister(Register register) throws Exception {
		// TODO Auto-generated method stub
		logger.debug("增加复兴报到人员+IRegisterService");
		return iregisterMapper.addRegister(register);
	}
	/**
	 *@author Administrator
	 *@注释 : 删除服刑报到人员
	 *	
	 */
	@Override
	public int delRegister(int id) throws Exception {
		// TODO Auto-generated method stub
		logger.debug("删除服刑报到人员+IRegisterService");
		return iregisterMapper.delRegister(id);
	}

	/**
	 * 批量删除报到信息
	 * @param list
	 * @return
	 * @throws Exception
     */
	@Override
	public int deleteBatch(List<Integer> list) throws Exception {
		return iregisterMapper.deleteBatch(list);
	}

	/**
	 *@author Administrator
	 *@注释 : 修改服刑报到人员
     *	
     */
	@Override
	public int editRegister(Register register) throws Exception {
		// TODO Auto-generated method stub
		logger.debug("修改服刑报到人员+IRegisterService");
		return iregisterMapper.editRegister(register);
	}
	/**
	 *@author Administrator
	 *@注释 : 模糊查询服刑报到人员
	*	
	*/
	@Override
	public Page getLikeRegister(Map<String, Object> register) throws Exception {
		// TODO Auto-generated method stub
		Page page=new Page();
		page.setTotalNum(iregisterMapper.getLikeRegisterCount(register));
		int pageSize=Integer.parseInt(String.valueOf(register.get("pageSize")));
		page.setPageSize(pageSize);
		int curPageNum=Integer.parseInt(String.valueOf(register.get("pageNum")));
		page.setCurPageNum(curPageNum);
		page.setTotalPage(page.getTotalNum()/pageSize+(page.getTotalNum()%pageSize==0?0:1));
		page.setResult(iregisterMapper.getLikeRegister(register));
		logger.debug("模糊查询监管等级 + IGradeServiceImpl");
		return page;
	}
	/**
	 *@author Administrator
	 *@注释 : 根据id查询服刑报到人员
	*	
	*/
	@Override
	public Map<String,Object> getIdRegister(int id) throws Exception {
	logger.debug("根据Id查询服刑报到人员+IRegisterService");	
	return iregisterMapper.getIdRegister(id);}
	@Override
	public List<Map<String, Object>> getAllRegister() throws Exception {
		// TODO Auto-generated method stub
		
		return iregisterMapper.getAllRegister();
	}


}
